using Godot;
using System;

public partial class FloatingText : Node2D
{
	Label label;
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		label = GetNode<Label>("Label");
	}

	public void Start(String text){
		label.Text = text;

		Tween tween = CreateTween();
		tween.SetParallel();

		tween.TweenProperty(this,"global_position", GlobalPosition + (Vector2.Up * 16), .3)
		.SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Cubic);
		
		tween.Chain();

		tween.TweenProperty(this,"global_position", GlobalPosition + (Vector2.Up * 48), .5)
		.SetEase(Tween.EaseType.In).SetTrans(Tween.TransitionType.Cubic);
		tween.TweenProperty(this,"scale",Vector2.One, .5)
		.SetEase(Tween.EaseType.In).SetTrans(Tween.TransitionType.Cubic);
		tween.Chain();

		tween.TweenCallback(Callable.From(QueueFree));

		Tween scaleTween = CreateTween();
		scaleTween.TweenProperty(this,"scale",Vector2.One * 1.5f, .15)
		.SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Cubic);
		scaleTween.TweenProperty(this,"scale",Vector2.One, .15)
		.SetEase(Tween.EaseType.In).SetTrans(Tween.TransitionType.Cubic);
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
	}
}
